package cn.lili.modules.member.serviceimpl;


import cn.lili.cache.Cache;
import cn.lili.common.vo.PageVO;
import cn.lili.modules.member.entity.dos.RechargeFow;
import cn.lili.modules.member.mapper.RechargeFowMapper;
import cn.lili.modules.member.service.RechargeFowService;
import cn.lili.mybatis.util.PageUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 会员等级接口业务层实现
 *
 * @author Chopper
 * @since 2021-03-29 14:10:16
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class RechargeFowServiceImpl extends ServiceImpl<RechargeFowMapper, RechargeFow> implements RechargeFowService {

    /**
     * 缓存
     */
    @Autowired
    private Cache cache;

    public IPage<RechargeFow> getRechargeFowPage(RechargeFow rechargeFow, PageVO page) {
        QueryWrapper<RechargeFow> queryWrapper = Wrappers.query();
        //流水号
            if(rechargeFow.getSerialNumber()!=null&&!rechargeFow.getSerialNumber().equals("")){
                queryWrapper.eq("serial_number", rechargeFow.getSerialNumber());
            }
        //交易类型
            if(rechargeFow.getRechargeType()!=null&&!rechargeFow.getRechargeType().equals("")){
                queryWrapper.eq("recharge_type", rechargeFow.getRechargeType());
            }
            //id
        if(rechargeFow.getId()!=null){
            queryWrapper.eq("a.id", rechargeFow.getId());
        }
        queryWrapper.orderByDesc("create_time");
        return this.baseMapper.getRechargeFowPage(PageUtil.initPage(page), queryWrapper);
    }

}